Using synapsis

Setup in Rstudio

installing library from gitlab

To use synapsis, you will need the following packages:

  • stats
  • EBImage
  • graphics
  • utils

And to run this tutorial, you will need:

  • tidyverse
  • ggplot2
  • knitr
  • rmarkdown
devtools::install_git('https://gitlab.svi.edu.au/lmcneill/synapsis')

loading synapsis

library(synapsis)

checking documentation

Data preparation

Please download test1.zip and test2.zip in the “coding” chat. Double click to unzip. Drag the folders into the place you’ll be working from, and make note of the path. For example, if I want to put them in a folder I created called “test-data-all” in “imaging”, in “svi”, in the “Documents” folder, my path looks like:

path = "~/Documents/svi/imaging/test-data-all"

Calling functions on data

Cropping routine.

You can type

??auto_crop_fast

There is an annotation setting, which we switch to “on”. max_cell_area and min_cell_area have been calibrated to our data set, where the subject are mouse cells and magnification kept constant. Let’s run it on the first five images by setting test_amount = 5

auto_crop_fast(path, annotation = "off", max_cell_area = 30000, min_cell_area = 7000, test_amount = 4)
## Warning in dir.create(paste0(img_path, "/crops")): '/Users/lmcneill/Documents/
## svi/imaging/test-data-all/crops' already exists
## [1] "out of"
## [1] 4
## [1] "images, we got"
## [1] 4
## [1] "viable cells"

Here we called path, plus other optional parameters (that would otherwise take on default values). But only path is essential. This is because auto_crop_fast has built-in default values which are assumed when the user doesn’t specify.

A crops folder with three channels per “viable cell” should have been generated inside the folder where these images are kept i.e. in path.

Getting pachytene

SYCP3_stats <- get_pachytene(path,ecc_thresh = 0.8, area_thresh = 0.04, annotation = "on")
## Warning in dir.create(paste0(img_path_new, "/pachytene")): '/Users/lmcneill/
## Documents/svi/imaging/test-data-all/crops/pachytene' already exists
## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0

## [1] "decided the following is pachytene"

## [1] "decided the following is pachytene"
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0

## [1] "number of cells kept"
## [1] 100

SYCP3_stats is a data frame summarising some features of the cells classified as pachytene.

Bigger data set.

Now we will run auto_crop on the bigger data set (silently/ without annotation) to do some significance testing.

## Warning in dir.create(paste0(img_path, "/crops")): '/Users/lmcneill/Documents/
## svi/imaging/test-data-all/crops' already exists
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "only 0's may be mixed with negative subscripts"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## List of 2
##  $ message: chr "subscript out of bounds"
##  $ call   : language slot(noise_gone, ".Data")[ix, iy, drop = FALSE]
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## [1] "out of"
## [1] 174
## [1] "images, we got"
## [1] 638
## [1] "viable cells"

Counting foci

Now let’s count the foci for each genotype.

SYCP3_stats <- get_pachytene(path,ecc_thresh = 0.8, area_thresh = 0.04, annotation = "off")
## Warning in dir.create(paste0(img_path_new, "/pachytene")): '/Users/lmcneill/
## Documents/svi/imaging/test-data-all/crops/pachytene' already exists
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 1 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 2 cannot be normalized as its diff(range)
## is 0
## Warning in .local(object, ...): frame 3 cannot be normalized as its diff(range)
## is 0
## [1] "number of cells kept"
## [1] 100
foci_counts <- count_foci(path,offset_factor = 3, brush_size = 3, brush_sigma = 3, annotation = "off",stage = "pachytene")
## Warning in mean.default(foci_areas): argument is not numeric or logical:
## returning NA
## List of 2
##  $ message: chr "numbers of columns of arguments do not match"
##  $ call   : language rbind(deparse.level, ...)
##  - attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
## [1] "couldn't crop it"

Make sure every line prior to the above chunk is commented out, because we want to knit with annotate = “on” to check that synapsis is counting close or same as a manual count.

If it’s identifying too many things as focis, try increasing some of the input parameters like offset_factor or brush_size. If it’s not identifying any foci but there are clearly foci there, try decreasing those parameters. # Statistics

some basic statistics

### comparing groups
counts <- foci_counts$foci_count
counts_mod <- foci_counts[as.numeric(foci_counts$foci_count) > 0,]
counts_mod <- foci_counts[as.numeric(foci_counts$foci_count) < 40,]
#counts_mod <- counts_mod[as.numeric(counts_mod$percent_on) > 0.55,]
# counts_mod <- counts_mod[as.numeric(counts_mod$sd_foci) <20,]
counts <- counts_mod$foci_count
counts_KO <- counts_mod[counts_mod$genotype == "Fancm-/-",]
counts_WT <- counts_mod[counts_mod$genotype == "Fancm+/+",]

count_KO <- counts_KO$foci_count
count_WT <- counts_WT$foci_count
mean(as.numeric(count_KO), na.rm= TRUE)
## [1] 25.73684
mean(as.numeric(count_WT), na.rm= TRUE)
## [1] 20.05714
sd(as.numeric(count_KO), na.rm= TRUE)
## [1] 11.11229
sd(as.numeric(count_WT), na.rm= TRUE)
## [1] 10.78382
c1 <- rgb(173,216,230,max = 255, alpha = 140, names = "lt.blue")
c4 <- rgb(255,180,50, max = 255, alpha = 120, names = "lt.orange")
A <- hist(as.numeric(count_WT),plot = FALSE)
B <-  hist(as.numeric(count_KO), plot = FALSE )
plot(A,ylim = c(0,20),  main = "Pachytene", col = c4, xlab = "foci count per cell") 
plot(B, col = c1, add = TRUE) 

comparison testing

anova test

## anova test
counts_mod$group <- factor(counts_mod$genotype, c("Fancm-/-", "Fancm+/+"))
outfit <- lm(foci_count ~ genotype, data=counts_mod)
outfit
## 
## Call:
## lm(formula = foci_count ~ genotype, data = counts_mod)
## 
## Coefficients:
##      (Intercept)  genotypeFancm+/+  
##            25.74             -5.68
#df.residual(outfit)
#sigma(outfit)
#model.matrix(outfit)
outfit0 <- lm(foci_count ~ 1, data=counts_mod)
anova(outfit0, outfit)
## Analysis of Variance Table
## 
## Model 1: foci_count ~ 1
## Model 2: foci_count ~ genotype
##   Res.Df   RSS Df Sum of Sq      F  Pr(>F)  
## 1     91 11568                              
## 2     90 10869  1    699.53 5.7924 0.01814 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

t test

t.test(as.numeric(count_KO),as.numeric(count_WT))
## 
##  Welch Two Sample t-test
## 
## data:  as.numeric(count_KO) and as.numeric(count_WT)
## t = 2.4243, df = 73.754, p-value = 0.01779
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   1.011203 10.348195
## sample estimates:
## mean of x mean of y 
##  25.73684  20.05714

now that we have a p value we can paste this on the histogram

c1 <- rgb(173,216,230,max = 255, alpha = 140, names = "lt.blue")
c4 <- rgb(255,180,50, max = 255, alpha = 120, names = "lt.orange")
A <- hist(as.numeric(count_WT),plot = FALSE)
B <-  hist(as.numeric(count_KO), plot = FALSE )
plot(A,ylim = c(0,20),  main = "Pachytene", col = c4, xlab = "foci count per cell") 
text(x = 10, y = 15, label = "anova p value = 0.01*", col = "black", cex = 1)
plot(B, col = c1, add = TRUE) 

#boxplot

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.1.2     ✓ dplyr   1.0.6
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
counts_mod %>% 
  ggplot(aes(x=genotype, y=as.numeric(foci_count), fill=genotype)) + 
  geom_boxplot(width=0.5,lwd=1.5) +
  geom_jitter(width=0.15)+
  labs(subtitle="MLH3 foci counts")

We won’t run this for the notebook yet:

df_dist <- measure_distances(path, annotation = "off")
print(df_dist)
pass_only <- df_dist[df_dist$pass_fail == "pass",]

distances <- pass_only$fractional_distance
distances_KO <- pass_only[pass_only$genotype == "Fancm-/-",]
distances_WT <- pass_only[pass_only$genotype == "Fancm+/+",]

distance_KO <- distances_KO$fractional_distance
distance_WT <- distances_WT$fractional_distance
mean(as.numeric(distance_KO), na.rm= TRUE)
mean(as.numeric(distance_WT), na.rm= TRUE)
sd(as.numeric(distance_KO), na.rm= TRUE)
sd(as.numeric(distance_WT), na.rm= TRUE)

c1 <- rgb(173,216,230,max = 255, alpha = 140, names = "lt.blue")
c4 <- rgb(255,180,50, max = 255, alpha = 120, names = "lt.orange")
A <- hist(as.numeric(distance_WT),plot = FALSE)
B <-  hist(as.numeric(distance_KO), plot = FALSE )
plot(A,ylim = c(0,9),xlim = c(0,1),  main = "Pachytene", col = c4, xlab = "foci distance as fraction of total length") 
text(x = 0.2, y = 7, label = "anova p value 0.9 (NS)", col = "black", cex = 1)
plot(B, col = c1, add = TRUE) 
t.test(as.numeric(distance_KO),as.numeric(distance_WT))
column <- as.data.frame(count_WT)
write.csv(column, "column4.csv",row.names = FALSE)